<?php
require(dirname(__FILE__) . '/includes/init.php');
if($_REQUEST['act'] == 'search'){
	$start_yema = $_REQUEST['start_yema'];
	$end_yema = $_REQUEST['end_yema'];
	if(empty($start_yema)){
		$start_yema = 1;
	}
	if(empty($end_yema)){
		$end_yema = 3;
	}
	$start_rank = ($start_yema-1)*36;
	$end_rank = $end_yema*36+1;
	$sql = "select add_time from ".$ecs->table('jingdong')." where id = (select max(id) from ".$ecs->table('jingdong').")";
	$addtime = $db->getOne($sql);
	$sql = "select provider,add_time,count(products_sn) as num from ".$ecs->table('jingdong')." where add_time='".$addtime."' and ranking>".$start_rank." and ranking<".$end_rank." group by provider order by num desc";  
	$provider_list = $db->getAll($sql);
    
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>管理中心 - 统计列表 </title>
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="styles/general.css" rel="stylesheet" type="text/css" />
<link href="styles/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
</head>
<body>
 
<h1>
<span class="action-span1"><a target="_top" href="index.php?act=main">管理中心</a> </span><span id="search_id" class="action-span1"> - 统计列表 </span>
<div style="clear:both"></div>
</h1>

<div class="form-div">
  <form action="e.php" method="post" name="searchForm" onsubmit="return search_yz()">
    <img src="images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH" />
    第<input name="start_yema" type="text" id="start_yema" size="4">页到
	第<input name="end_yema" type="text" id="end_yema" size="4">页
	<input type="hidden" name="act" value="search" />
    <input type="submit" value=" 搜索 " class="button" />
  </form>
</div>
<script type="text/javascript">
function search_yz(){
	var start_yema = $("#start_yema").val();
	var end_yema = $("#end_yema").val();
	if(start_yema.replace(/[ ]/g,"")==""){
		start_yema = 1;
	}
	if(end_yema.replace(/[ ]/g,"")==""){
		end_yema = 3; 
	}
	if(isNaN(start_yema)||isNaN(end_yema)){
		alert("请输入数字");
		return false;
	}else{
		return true;
	}
}
</script> 
<!-- 订单列表 -->
  <div class="list-div" id="listDiv">
<table cellpadding="3" cellspacing="1">
  <tr>
    <th>排名</th>
    <th>商家名</th>
    <th>产品数量</th>
    <th>时间</th>
    <th>操作</th>
  <tr>
  <?php 
    $i=0;
	if(count($provider_list)>0){
	foreach($provider_list AS $index => $array_val){
		$i++;
  ?>
   <tr>
    <td><?php echo $i;?></td>
    <td><?php echo $array_val['provider'];?></td>
    <td><?php echo $array_val['num'];?></td>
	<td><?php echo date('Y-m-d H:i:s',$array_val['add_time']);?></td>
	<td>
		<form action="provider_detail.php" method="post">
			<input type="hidden" name="provider" value="<?php echo $array_val['provider'];?>" />
			<input type="hidden" name="start_ye" value="<?php echo $start_yema;?>" />
			<input type="hidden" name="end_ye" value="<?php echo $end_yema;?>" />
			<input type="hidden" name="add_time" value="<?php echo $array_val['add_time'];?>" />
			<input type="hidden" name="act" value="view" />
			<input type="submit" value="查看" class="button"/>
		</form>
	</td>
  <tr>
  <?php 
      } 
	}
  ?>
  </table>
 
<!-- 分页 -->
  </div>
</body>
</html>